/**
 * 
 */
package com.ly.hotel.view.fragments.music;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;

import androidx.viewpager.widget.ViewPager;

import com.ly.hotel.R;
import com.ly.hotel.adaptor.HardwareInterface;
import com.ly.hotel.common.Constants;
import com.ly.hotel.common.MyApplication;
import com.ly.hotel.common.MyLogsManager;
import com.ly.hotel.model.MusicAlbumBean;
import com.ly.hotel.model.MusicBean;
import com.ly.hotel.msgevent.GetMusicEvent;
import com.ly.hotel.msgevent.SendLogEvent;
import com.ly.hotel.msgevent.UpdateMusicEvent;
import com.ly.hotel.util.ProcessWaitingUtil;
import com.ly.hotel.util.ToastUtil;
import com.ly.hotel.view.common.BaseActivity;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import de.greenrobot.event.EventBus;

/**
 * @author jouson
 * 
 */
public class MusicActivity extends BaseActivity {
	private static final String TAG = "MusicActivity";
	private MyApplication app;

	private String playeringName = "";

	// 内容
	private List<MusicAlbumBean> albumViewList = new ArrayList<MusicAlbumBean>();
	private List<List<MusicAlbumBean>> lMuList = new ArrayList<List<MusicAlbumBean>>();
	// view
	private ViewPager mAlbumViewPager;
	//导航栏
	private LinearLayout viewPageTool;

	//左滑View
	private ImageView toLeftView;

	//右滑view
	private ImageView toRightView;

	private MusicAlbumBean curAlbum;

	// 音乐播放部分
	private MediaPlayer player;
	private TextView startTime;
	private TextView endTime;
	private TextView songname;
	private ImageButton playerfrist;
	private ImageButton playernext;
	private ImageButton playerstop;
	private ImageButton volumesub;
	private ImageButton volumeadd;
	private ImageButton forwardbt;
	private ImageButton backwardbt;
	private ImageButton playerlist;

	private SeekBar music_seekBar;
	private SeekBar volume_seekBar;

	private int maxVolume = 100;
	private int currentVolume = 0;

	private int staTimeStr = 0;
	private int endTimeStr = 0;
	private boolean isTimeChang = false;

	private boolean isPlaying = false;

	private int position = -1;




	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_music);
		app = (MyApplication) getApplicationContext();

		findView();
		setListener();

		HardwareInterface.setMuteFlag(false);
		// 最大音量
		maxVolume = HardwareInterface.getMaxVolume();

		// 获取音量
		currentVolume = HardwareInterface.getVolume();

		//当前音量大于设定最大音量时
		if(currentVolume > maxVolume){
			currentVolume = maxVolume;
			HardwareInterface.setVolume(currentVolume);
		}
		initMusicView();

		myhandler.postDelayed(handlerMusicinit, 100);
	}

	@Override
	public void onStart() {
		super.onStart();
	}

	Runnable handlerMusicinit = new Runnable() {
		@Override
		public void run() {
			try{
				seekBarListene();
				setMediaListene();
				updateMusicAreaListView();
			} catch (Exception e){
				e.printStackTrace();
				Log.e(TAG, "音乐页面初始化出错了");
			}
		}
	};

	@Override
	public void onPause() {
		super.onPause();
		Log.i(TAG, "音乐退出之");
		HardwareInterface.setMuteFlag(true);

		try {
			if (player != null) {
				stopMusic();
				clearMusicPlayList();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		MyApplication.musicPlayList.clear();
	}

	@Override
	public void onResume() {
		super.onResume();
		if(player != null){
			for(MusicBean b : MyApplication.musicPlayList){
				Log.i(TAG, b.getName());
			}
			music_seekBar.setEnabled(true);
			restMusic();
		}
	}

	@Override
	public void onStop() {
		super.onStop();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	private void findView() {
		// 专辑浏览栏
		mAlbumViewPager = (ViewPager) findViewById(R.id.mAlbumViewPager);
		viewPageTool = (LinearLayout) findViewById(R.id.music_tool);
		toLeftView = (ImageView) findViewById(R.id.music_left_more);
		toRightView = (ImageView) findViewById(R.id.music_right_more);

		TextView mtitle = (TextView) findViewById(R.id.muc_title).findViewById(R.id.activity_name);
		mtitle.setText(R.string.naviMusicName);
	}

	private void setListener() {
		mAlbumViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

			@Override
			public void onPageSelected(int arg0) {
				int c = lMuList.size();
				if(c > 1){
					if(arg0 == 0){
						toLeftView.setVisibility(View.INVISIBLE);
						toRightView.setVisibility(View.VISIBLE);
					} else if(arg0 + 1 == c){
						toRightView.setVisibility(View.INVISIBLE);
						toLeftView.setVisibility(View.VISIBLE);
					} else {
						toLeftView.setVisibility(View.VISIBLE);
						toRightView.setVisibility(View.VISIBLE);
					}
				}
				setButtonColor(arg0);
			}

			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub
			}

			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub
			}
		});

		toLeftView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				int npos = mAlbumViewPager.getCurrentItem();
				if(npos > 0){
					mAlbumViewPager.setCurrentItem(npos-1);
				}
			}
		});

		toRightView.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				int npos = mAlbumViewPager.getCurrentItem();
				if((npos + 1) < lMuList.size()){
					mAlbumViewPager.setCurrentItem(npos+1);
				}
			}
		});
	}

	public void albumGridViewProcess(MusicAlbumBean b) {
		curAlbum = b;
		if( b.getMusicPages() != null && b.getMusicPages().size()>0){
			showMusicDialog(curAlbum);
		}else{
			GetMusicEvent e = new GetMusicEvent(Constants.GET_MUSIC_LIST);
			e.setAlbumId(b.getAlbumId());
			EventBus.getDefault().post(e);
			ProcessWaitingUtil.showProcessDialog(this, "加载中..", 5000);
		}
	}

	//专辑详情
	public void showMusicDialog(MusicAlbumBean b){
		MusicListDialog itemDialog = new MusicListDialog(this, R.style.introDialog,b);	//创建Dialog并设置样式主题
		itemDialog.setCanceledOnTouchOutside(true);//设置点击Dialog外部任意区域关闭Dialog
		itemDialog.show();
	}

	//播放列表
	public void showMusicListDialog(List<MusicBean> lb){
		MusicPlayerListDialog listDialog = new MusicPlayerListDialog(this, R.style.introDialog,lb);	//创建Dialog并设置样式主题
		listDialog.setCanceledOnTouchOutside(true);//设置点击Dialog外部任意区域关闭Dialog
		listDialog.show();
	}

	//专辑列表页面点击歌曲
	public void playerMusicFromPlayList(int position){
		if(MyApplication.musicPlayList.get(position).getName().equals(playeringName)){
			playerOrpause();
		}else {
			try {
				playerSong(position);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	//清空播放列表
	public void clearMusicPlayList() {
		if (MyApplication.musicPlayList != null) {
			MyApplication.musicPlayList.clear();
		}
	}

	//加入整张专辑到列表
	public void addMusicToPlayList(List<MusicBean> mb, int position) {
		boolean autoplay = false;
		if(MyApplication.musicPlayList == null || MyApplication.musicPlayList.size() == 0){
			autoplay = true;
		}

		if (position >= 0) {
			if(mb.get(position).getName().equals(playeringName) && MyApplication.musicPlayList.size()>0){
				playerOrpause();
			}else {
				MyApplication.musicPlayList.clear();
				MyApplication.musicPlayList.addAll(mb);
				try {
					playerSong(position);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}else{
			MyApplication.musicPlayList.addAll(mb);
			Toast.makeText(this,"成功！  Success！",Toast.LENGTH_SHORT).show();
			if(autoplay && MyApplication.musicPlayList.size() > 0){
				try {
					playerSong(0);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}

	//加入单曲到列表，如果是第一首就播放
	public void addMusicToPlayList(MusicBean b) {
		MyApplication.musicPlayList.add(b);
		Toast.makeText(this,"成功！  Success！",Toast.LENGTH_SHORT).show();
		if (MyApplication.musicPlayList.size() == 1) {
			try {
				playerSong(0);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	private void updateMusicAreaListView() {
		List<MusicAlbumBean> musicRepos = app.getMusicRepos();
		albumViewList.clear();

		/* 初始化类型 */
		if (musicRepos != null && musicRepos.size()>0) {
			albumViewList.addAll(musicRepos);
			getListIntArray(albumViewList,10);
		} else {
			EventBus.getDefault().post(new GetMusicEvent(Constants.GET_MUSIC_ALBUM_LIST));
			ProcessWaitingUtil.showProcessDialog(this, "Loading..", 3000);
		}

	}

	@SuppressWarnings("deprecation")
	private void getListIntArray(List<MusicAlbumBean> v, int s) {
		lMuList.clear();
		int t = v.size();
		for (int i = 0; i < t; i = i + s) {
			int fromIndex = i;
			int toIndex = i + s;
			if (toIndex >= t) {
				toIndex = t;
			}
			List<MusicAlbumBean> nv = v.subList(fromIndex, toIndex);
			lMuList.add(nv);
		}
		MusicAlbumListAdapter adpter = new MusicAlbumListAdapter(this, lMuList);
		mAlbumViewPager.setAdapter(adpter);
		mAlbumViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.px120));
		mAlbumViewPager.setOffscreenPageLimit(3);
		mAlbumViewPager.post(new Runnable() {
			@Override
			public void run() {
				mAlbumViewPager.requestFocus();
				mAlbumViewPager.requestFocusFromTouch();
			}
		});
		if(lMuList.size() > 1){
			viewPageTool.removeAllViews();
			toRightView.setVisibility(View.VISIBLE);
			LayoutInflater inflater = LayoutInflater.from(this);
			for(int i =0 ;i<lMuList.size();i++){
				View view = inflater.inflate(R.layout.music_tool_btn, null);
				Button tmpBtn = (Button) view.findViewById(R.id.m_tool_btn);
				tmpBtn.setText((i +1) + "");
				viewPageTool.addView(view);
				final int pos = i;
				tmpBtn.setOnFocusChangeListener(new View.OnFocusChangeListener() {

					@Override
					public void onFocusChange(View arg0, boolean arg1) {
						// TODO Auto-generated method stub
						if(arg1){
							mAlbumViewPager.setCurrentItem(pos);
						}
					}
				});
				tmpBtn.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						arg0.requestFocus();
						arg0.requestFocusFromTouch();
					}
				});
				setButtonColor(0);
			}
		}
	}

	//设置背景颜色
	private void setButtonColor(int pos){
		if(viewPageTool.getChildCount()>0){
			for(int i=0;i<viewPageTool.getChildCount();i++){
				if(viewPageTool.getChildAt(i).getClass().getName().contains("LinearLayout")){
					Button b = (Button) viewPageTool.getChildAt(i).findViewById(R.id.m_tool_btn);
					if(i == pos){
						b.setTextColor(Color.parseColor("#ff7e00"));
					}else{
						b.setTextColor(Color.parseColor("#bbbbbb"));
					}
				}
			}
		}
	}

	private void setMediaListene() {
		player = new MediaPlayer();
		player.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				System.out.println("music onPrepared");
				music_seekBar.setEnabled(true);
				playerfrist.setEnabled(true);
				playernext.setEnabled(true);
				playerstop.setEnabled(true);
				isTimeChang = true;
				isPlaying = true;
				mp.start();
				HardwareInterface.setMuteFlag(false);
				playerstop.setBackgroundResource(R.drawable.music_stop);
				endTimeStr = mp.getDuration();
				myhandler.sendEmptyMessage(handles.ENDTIMESTRCHANG);
			}
		});

		player.setOnCompletionListener(new OnCompletionListener() {
			@Override
			public void onCompletion(MediaPlayer mp) {
				if (MyApplication.musicPlayList.size() > 0) {
					try {
						if (++position < MyApplication.musicPlayList.size()) {
							playerSong(position);
						} else {
							playerSong(0);
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}else{
					stopMusic();
				}
			}
		});
	}

	private void seekBarListene() {
		// 控制音量
		volume_seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
			}

			@Override
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
				currentVolume = progress;
				if (myhandler != null) {
					if (myhandler.hasMessages(4)) {
						myhandler.removeMessages(4);
					}
					myhandler.sendEmptyMessageDelayed(4,100);
				}
				if (currentVolume > 0) {
					volumesub.setBackgroundResource(R.drawable.music_volume_sub);
				} else {
					volumesub.setBackgroundResource(R.drawable.music_volume_novolume);
				}
			}
		});

		// 音乐播放位置
		music_seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			@Override
			public void onStopTrackingTouch(SeekBar seekBar) {
				if (isPlaying) {
					player.seekTo(seekBar.getProgress());
					staTimeStr = player.getCurrentPosition();
					startTime.setText(getTimeStr(staTimeStr));
				}
			}

			@Override
			public void onStartTrackingTouch(SeekBar seekBar) {
			}

			@Override
			public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {

			}
		});

		backwardbt.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (myhandler.hasMessages(6)) {
					myhandler.removeMessages(6);
				}
				myhandler.sendEmptyMessageDelayed(6,100);
			}
		});

		forwardbt.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (myhandler.hasMessages(5)) {
					myhandler.removeMessages(5);
				}
				myhandler.sendEmptyMessageDelayed(5,100);
			}
		});
	}

	/* 设置快进10秒方法
	 */
	public void forWard(){
		if(player != null && isPlaying){
			int position = player.getCurrentPosition();
			player.seekTo(position + 10000);
		}
	}

	/* 设置后退10秒的方法
	 */
	public void backWard(){
		if(player != null && isPlaying){
			int position = player.getCurrentPosition();
			if(position > 10000){
				position-=10000;
			}else{
				position = 0;
			}
			player.seekTo(position);
		}
	}

	Handler myhandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
				case handles.ENDTIMESTRCHANG:
					try {
						endTime.setText(getTimeStr(endTimeStr));
						staTimeStr = player.getCurrentPosition();
						setPlayTime();
						myhandler.sendEmptyMessage(handles.SEEKBARCHANG);
					} catch (Exception e) {
						e.printStackTrace();
					}
					break;
				case handles.STARTIMESTRCHANG:
					try {
						if (isPlaying && player.isPlaying()) {
							staTimeStr = player.getCurrentPosition();
							startTime.setText(getTimeStr(staTimeStr));
							music_seekBar.setProgress(staTimeStr);
						}
					} catch (Exception e) {
						e.printStackTrace();
					}

					break;
				case handles.SEEKBARCHANG:
					new Thread(new Runnable() {
						@Override
						public void run() {
							while (isTimeChang) {
								try {
									myhandler.sendEmptyMessage(handles.STARTIMESTRCHANG);
									Thread.sleep(1000);
								} catch (InterruptedException e) {
									e.printStackTrace();
								}
							}
						}
					}).start();
					break;

				case handles.SETVOLUME:
					HardwareInterface.setVolume(currentVolume);
					break;
				case handles.PLAYSEEKADD:
					forWard();
					break;
				case handles.PLAYSEEKSUB:
					backWard();
					break;

			}
		};
	};

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		if(keyCode == KeyEvent.KEYCODE_VOLUME_UP){
			int newVol = volume_seekBar.getProgress() + 4;
			volume_seekBar.setProgress(newVol);
			return true;
		}else if(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
			int newVol = volume_seekBar.getProgress() - 4;
			volume_seekBar.setProgress(newVol);
			return true;
		}else{
			return super.onKeyDown(keyCode, event);
		}
	}

	// 设置音量
	private void setVolum() {
		volume_seekBar.setMax(maxVolume);
		volume_seekBar.setProgress(currentVolume);
	}

	// 设置音乐播放时间
	private void setPlayTime() {
		music_seekBar.setMax(endTimeStr);
		music_seekBar.setProgress(staTimeStr);
	}

	public void initMusicView() {
		songname = (TextView) findViewById(R.id.listTitleTxt);
		playerfrist = (ImageButton) findViewById(R.id.playerfrist);
		playernext = (ImageButton) findViewById(R.id.playernext);
		playerstop = (ImageButton) findViewById(R.id.playerstop);
		volumesub = (ImageButton) findViewById(R.id.music_volume);
		volumeadd = (ImageButton) findViewById(R.id.music_volume_add);
		forwardbt = (ImageButton) findViewById(R.id.playerforward);
		backwardbt = (ImageButton) findViewById(R.id.playerbackward);
		playerlist = (ImageButton) findViewById(R.id.playerlist);
		music_seekBar = (SeekBar) findViewById(R.id.payler_sebar);
		volume_seekBar = (SeekBar) findViewById(R.id.volume_sebar);
		startTime = (TextView) findViewById(R.id.statrtime);
		endTime = (TextView) findViewById(R.id.endtime);

		music_seekBar.setEnabled(false);
		setVolum();

		playerfrist = (ImageButton) findViewById(R.id.playerfrist);
		playernext = (ImageButton) findViewById(R.id.playernext);
		playerfrist.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if(MyApplication.musicPlayList.size() > 0) {
					try {
						if (--position > 0) {
							playerSong(position);
						} else {
							playerSong(MyApplication.musicPlayList.size() -1);
						}
					} catch (IllegalStateException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
		});
		playernext.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if(MyApplication.musicPlayList.size() > 0) {
					try {
						if (++position < MyApplication.musicPlayList.size()) {
							playerSong(position);
						} else {
							playerSong(0);
						}
					} catch (IllegalStateException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
		});

		// 播放或者停止
		playerstop.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				playerOrpause();
			}
		});

		//音量减遥控使用
		volumesub.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				int newVol = volume_seekBar.getProgress() - 4;
				volume_seekBar.setProgress(newVol);
			}
		});

		//音量加遥控使用
		volumeadd.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				int newVol = volume_seekBar.getProgress() + 4;
				volume_seekBar.setProgress(newVol);
			}
		});

		//播放列表
		playerlist.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				showMusicListDialog(MyApplication.musicPlayList);
			}
		});
	}

	// 获取歌曲时间
	@SuppressLint("SimpleDateFormat")
	private String getTimeStr(int time) {
		return new SimpleDateFormat("mm:ss").format(new Date(time));
	}

	// 常量（handler所使用）
	private final class handles {
		public static final int STARTIMESTRCHANG = 1;
		public static final int ENDTIMESTRCHANG = 2;
		public static final int SEEKBARCHANG = 3;
		public static final int SETVOLUME = 4;
		public static final int PLAYSEEKADD = 5;
		public static final int PLAYSEEKSUB = 6;
	}

	private void playerOrpause(){
		if(!TextUtils.isEmpty(playeringName)) {
			if (isTimeChang) {
				pauseMusic();
			} else {
				restMusic();
			}
		}else{
			ToastUtil.showShortToast(this, "请选择音乐再播放！ Please choose a song!", 2000);
		}
	}

	// 停止播放
	private void stopMusic() {
		isTimeChang = false;
		startTime.setText("00:00");
		endTime.setText("00:00");
		songname.setText(getResources().getString(R.string.music_play_title));
		playeringName = "";
		staTimeStr = 0;
		endTimeStr = 0;
		music_seekBar.setProgress(0);
		if (isPlaying) {
			isPlaying = false;
			player.stop();
		}
		playerstop.setBackgroundResource(R.drawable.music_start);
	}

	// 暂停播放
	private void pauseMusic() {
		isTimeChang = false;
		if (isPlaying) {
			player.pause();
		}
		playerstop.setBackgroundResource(R.drawable.music_start);
	}

	// 继续播放
	private void restMusic() {
		isTimeChang = true;
		myhandler.sendEmptyMessage(handles.SEEKBARCHANG);
		if (isPlaying) {
			player.start();
		}
		playerstop.setBackgroundResource(R.drawable.music_stop);
	}

	// 播放哪一首歌
	private void playerSong(int index) throws IllegalStateException, IOException {
		player.stop();
		player.reset();
		music_seekBar.setEnabled(false);
		playerfrist.setEnabled(false);
		playernext.setEnabled(false);
		playerstop.setEnabled(false);
		position = index;
		// 播放器不能正确识别空格，需要转换一下
		if (index < 0 || index >= MyApplication.musicPlayList.size()) {
			return;
		}

		String name = MyApplication.getHostResUrl() + MyApplication.musicPlayList.get(index).getAddr();
		name = name.replace(" ", "%20");

		try {
			songname.setText(getResources().getString(R.string.music_play_title) + MyApplication.musicPlayList.get(index).getName());
			playeringName = MyApplication.musicPlayList.get(index).getName();
			EventBus.getDefault().post(new SendLogEvent(MyLogsManager.CLOUD_LOGS_MUSIC_SONG_PREFIX + MyApplication.musicPlayList.get(index).getArea()
					+ "\t" + MyApplication.musicPlayList.get(index).getAlbumName()
					+ "\t" + MyApplication.musicPlayList.get(index).getName()));
			player.setDataSource(this, Uri.parse(name));
		} catch (Exception e) {
			e.printStackTrace();
		}
		player.prepareAsync();
	}

	public void onEventMainThread(UpdateMusicEvent e) {
		final int fnc = e.getEventType();
		Log.i(TAG, "更新音乐数据.getEventType=" + fnc);
		if (fnc == Constants.GET_MUSIC_ALBUM_LIST) {
			// 获取专辑数据
			updateMusicAreaListView();
		} else if (fnc == Constants.GET_MUSIC_LIST) {
			// 获取音乐列表
			showMusicDialog(curAlbum);
		}
		ProcessWaitingUtil.closeProcessDialog();
	}
}